import PropTypes from 'prop-types';
import React from 'react';
import { withRouter } from 'react-router';

import Asset from './Asset';
import Aviliable from './Aviliable';
import Vul from './Vul';
import Ssl from './Ssl';
import SecurityEvent from './SecurityEvent';
import Content from './Content';
import ChangeCheck from './ChangeCheck';
import Host from './host';
const componentMap = {
	asset: Asset,
	aviliable: Aviliable,
	vul: Vul,
	ssl: Ssl,
	securityEvent: SecurityEvent,
	content: Content,
	changeCheck: ChangeCheck,
	host: Host,
};

class Table extends React.PureComponent {
	static propTypes = {
		className: PropTypes.string,
		category: PropTypes.string,
		location: PropTypes.shape({
			search: PropTypes.string,
		}),
		history: PropTypes.shape({
			replace: PropTypes.func,
		}),
		getDropdownRef: PropTypes.func,
	};

	static defaultProps = {
		className: '',
	};

	render() {
		const { className, category, ...props } = this.props;
		const View = componentMap[category];

		return <View className={className} category={category} {...props} />;
	}
}

export default withRouter(Table);
